import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

import replicant2.Replicant2;


public class Test {
	
	public static void main(String[] args) throws Exception {

		 String msg = "Hello";
		 InetAddress group = InetAddress.getByName("228.5.6.7");
		 MulticastSocket s = new MulticastSocket(6789);
		 s.joinGroup(group);
		 DatagramPacket hi = new DatagramPacket(msg.getBytes(), msg.length(),group, 6789);
		 s.send(hi);
		 s.send(hi);
		 // get their responses!
		 
		 while(true){                           
		 byte[] buf = new byte[1000];
		 DatagramPacket recv = new DatagramPacket(buf, buf.length);
		 s.receive(recv);
		 System.out.println("receive messge:"+recv.getData().toString());
		 }
		 // OK, I'm done talking - leave the group...
		 //s.leaveGroup(group);
	}

}
